package org.trade.coupon.server;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.XmlWebApplicationContext;
import org.trade.common.constant.TradeEnums;

public class CouponRestServer {
	public static void main(String[] args) throws Exception {
		Server server = new Server(TradeEnums.RestServerEnum.COUPON.getServerPort());
		ServletContextHandler springMvcHandler = new ServletContextHandler();
		springMvcHandler.setContextPath("/" + TradeEnums.RestServerEnum.COUPON.getContextPath());
		XmlWebApplicationContext context = new XmlWebApplicationContext();
		context.setConfigLocation("classpath:xml/spring-web-coupon.xml");
		springMvcHandler.addEventListener(new ContextLoaderListener(context));
		// springMvcHandler.addServlet(new ServletHolder(new
		// DispatcherServlet(context)), "/*");
		server.setHandler(springMvcHandler);
		server.start();
		server.join();
	}

}
